<?php
/**
 * Created by PhpStorm.
 * User: sqq
 * Date: 2018/05/24
 * Time: 上午11:45
 */
class KingGlorySupportCount extends Eloquent
{
    protected $primaryKey = 'id';
    protected $table = "kingglory_support_count";

    public static function insertcount($team_id){
        $bbr=new KingGlorySupportCount();
        $bbr->team_id=$team_id;
        $bbr->num = '1';
        $bbr->created_at=date("Y-m-d H:i:s",time());
        $bbr->updated_at=date("Y-m-d H:i:s",time());
        $bbr->save();
        $team = KingGlorySupportCount::where("team_id",$team_id)->select("team_id","num")->first();
        return $team;
    }


    public static function updatecount($team_id,$num){
        DB::update("update kingglory_support_count set num=1+?,updated_at=? where team_id=?",array($num,date("Y-m-d H:i:s",time()),$team_id));
        $team = KingGlorySupportCount::where("team_id",$team_id)->select("team_id","num")->first();
        return $team;
    }
}